package com.teamin.service;

import com.teamin.entity.CircleLogEntity;
import com.teamin.entity.TaskLogEntity;

import java.util.List;

/**
 * 日志服务
 */
public interface LogService {

    int insertCircleLog(Long circleId, HANDLE handle, CircleHandleField handleField, Long handleUser, String handleUserName, String value);

    int insertCircleLog(Long circleId, HANDLE handle, CircleHandleField handleField, Long handleUser, String handleUserName, String value, String oldValue);

    int insertTaskLog(Long tasskId, HANDLE handle, TaskHandleField handleField, Long handleUser, String handleUserName, String value);

    int insertTaskLog(Long tasskId, HANDLE handle, TaskHandleField handleField, Long handleUser, String handleUserName, String value, String oldValue);

    List<TaskLogEntity> selectTaskLog(Long taskId);

    List<CircleLogEntity> selectCircleLog(Long circleId);

    /**
     * 日志操作类
     */
    public enum HANDLE {

        ADD(1, "add"),//新增
        UPDATE(2, "update"),//更新
        DELETE(3, "delete"),//删除
        MODIFY(4, "modify"),//修改
        OPEN(5, "open"),//打开
        CLOSE(6, "close"),//关闭
        INVITE(7, "invite"),//邀请
        CREATE(8, "create"),//创建
        CLEAR(9, "clear");//清除

        private final short type;

        private final String desc;

        HANDLE(int value, String message) {
            this.type = (short) value;
            this.desc = message;
        }

        public short value() {
            return this.type;
        }

        public String getValue() {
            return this.desc;
        }
    }

    /**
     * 操作的字段
     */
    public enum CircleHandleField {

        CIRCLE(1, "circle"),//圈子
        CIRCLE_NAME(2, "circle_name"),//圈子名称
        CIRCLE_USER_NICKNAME(3, "circle_user_nickname"),//用户昵称
        CIRCLE_SHARE(4, "circle_share"),//圈子分享
        CIRCLE_INVITE(5, "circle_invite"),//圈子邀请
        CIRCLE_AUTHORITY_CHECK(6, "circle_authority_check"),//圈子权限
        CIRCLE_MEMBER(7, "circle_member"),//圈子成员
        CIRCLE_MEMBER_MYSELF(8, "circle_member_myself"),//圈子成员自已
        CIRCLE_CREATER(9, "circle_creater"),//圈子创建者
        CIRCLE_TASK(10, "circle_task"),//圈子任务
        CIRCLE_SHARE_GROUP(11, "circle_share_group"),//圈子到群分享
        CIRCLE_SHARE_USER(12, "circle_share_user"),//圈子分享给用户
        CIRCLE_LABEL(13, "circle_label");//圈子标签

        private final short type;

        private final String desc;

        CircleHandleField(int value, String message) {
            this.type = (short) value;
            this.desc = message;
        }

        public short value() {
            return this.type;
        }

        public String getValue() {
            return this.desc;
        }
    }

    /**
     * 任务操作的字段
     */
    public enum TaskHandleField {

        TASK(1, "task"),//任务
        TASK_NAME(2, "task_name"),//任务名称
        TASK_ASSIGNER(3, "task_assigner"),//任务执行者
        TASK_PLAN_FINISH_TIME(4, "task_plan_finish_time"),//任务截止时间
        TASK_DESCRIPTION(5, "task_description"),//任务描述
        TASK_USER_ATTENTION(6, "task_user_attention"),//关注者
        TASK_LABEL(7, "task_label"),
        TASK_FILE_NAME(8, "task_file_name"),//圈子文档重命名
        TASK_FILE(9, "task_delete_file");  //圈子删除来自任务附近;//标签

        private final short type;

        private final String desc;

        TaskHandleField(int value, String message) {
            this.type = (short) value;
            this.desc = message;
        }

        public short value() {
            return this.type;
        }

        public String getValue() {
            return this.desc;
        }
    }

}
